home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML Authority.sea / XML Authority / Required / ccs_util.jar / regex / RTree.class (.txt) < prev   
Encoding:
Java Class File  |  1999-12-09  |  1.7 KB  |  75 lines

  1. package regex;
  2.  
  3. class RTree {
  4.    public static final int OP_EMPTY = 0;
  5.    public static final int OP_CHAR = 1;
  6.    public static final int OP_CONCAT = 2;
  7.    public static final int OP_UNION = 3;
  8.    public static final int OP_CLOSURE = 4;
  9.    public static final int OP_LHEAD = 5;
  10.    public static final int OP_LTAIL = 6;
  11.    private int operation;
  12.    private Chars chars;
  13.    private RTree left;
  14.    private RTree right;
  15.  
  16.    public int operation() {
  17.       return this.operation;
  18.    }
  19.  
  20.    public void removeChars(Chars var1) {
  21.       if (this.operation == 1 && this.chars.hasChars(var1)) {
  22.          if (var1.begin() <= this.chars.begin() && this.chars.end() <= var1.end()) {
  23.             this.chars.setType(4);
  24.             return;
  25.          }
  26.  
  27.          if (var1.begin() <= this.chars.end() && this.chars.end() <= var1.end()) {
  28.             this.chars.setEnd((char)(var1.begin() - 1));
  29.          } else if (var1.begin() <= this.chars.begin() && this.chars.begin() <= var1.end()) {
  30.             this.chars.setBegin((char)(var1.end() + 1));
  31.          } else if (this.chars.begin() <= var1.begin() && var1.end() <= this.chars.end()) {
  32.             this.operation = 3;
  33.             this.left = new RTree(new Chars(this.chars.begin(), (char)(var1.begin() - 1)));
  34.             this.right = new RTree(new Chars((char)(var1.end() + 1), this.chars.end()));
  35.          }
  36.       }
  37.  
  38.       if (this.left != null) {
  39.          this.left.removeChars(var1);
  40.       }
  41.  
  42.       if (this.right != null) {
  43.          this.right.removeChars(var1);
  44.       }
  45.  
  46.    }
  47.  
  48.    public RTree(Chars var1) {
  49.       this(1, var1, (RTree)null, (RTree)null);
  50.    }
  51.  
  52.    public RTree(int var1, RTree var2, RTree var3) {
  53.       this(var1, (Chars)null, var2, var3);
  54.    }
  55.  
  56.    public RTree(int var1, Chars var2, RTree var3, RTree var4) {
  57.       this.operation = var1;
  58.       this.chars = var2;
  59.       this.left = var3;
  60.       this.right = var4;
  61.    }
  62.  
  63.    public RTree left() {
  64.       return this.left;
  65.    }
  66.  
  67.    public RTree right() {
  68.       return this.right;
  69.    }
  70.  
  71.    public Chars chars() {
  72.       return this.chars;
  73.    }
  74. }
  75.